<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Upload_multi {

    private $CI;

    function Upload_multi() {
        $this->CI = & get_instance();
        $this->CI->load->helper(array('form', 'url'));
    }

    function do_upload()
    {
        $cur = date('mY', microtime(true));
        $config['upload_path'] = FCPATH.'uploads/topics/' . $cur . '/';
        $config['allowed_types'] = 'jpg|png|gif|jpeg';
        $this->CI->load->library('Upload', $config);
        if (!$this->CI->upload->do_multi_upload('images')) {
            return json_encode(array('status' =>false,'msg'=>$this->CI->upload->display_errors()));
        } else {
            $data = $this->CI->upload->get_multi_upload_data();
            return json_encode(array('status' =>true,'data'=>$data));
        }
    }
}